my_str = "itheima and itcast"
value = my_str[2]
value2 = my_str[-16]

print(value, value2)
# index方法
index = my_str.index("and")
print(index)

# replace方法
new_my_str = my_str.replace("it", "程序")
print(f"将字符串{my_str},替换后得到：{new_my_str}")

# split方法
my_str = "hello python itheima itcast"
my_str_list = my_str.split(" ")
print(f"分割后:{my_str_list},类型是：{type(my_str_list)}")

# strip方法
my_str = "  itheima and itcast  "
new_my_str = my_str.strip()
print(f"去除首尾空格后：{new_my_str}")
my_str = "12itheima and itcast11222"
new_my_str = my_str.strip("12")
print(f"去除首尾'1'与'2'后：{new_my_str}")

# count方法
my_str = "itheima and itcast"
print(f"it字符串出现的次数：{my_str.count('it')}")

# len方法
my_str = "itheima and itcast"
print(f"长度为：{len(my_str)}")

# 循环遍历
index = 0
while index < len(my_str):
    print(my_str[index], end='')
    index += 1

print()

for i in my_str:
    print(i, end="")
